package b.r;

import android.view.View;
import android.view.View.OnAttachStateChangeListener;
import android.view.ViewGroup;
import android.view.ViewTreeObserver.OnPreDrawListener;
import androidx.transition.AutoTransition;
import androidx.transition.Transition;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Iterator;

/* compiled from: TransitionManager */
public class g {
    public static Transition a = new AutoTransition();
    public static ThreadLocal<WeakReference<b.f.a<ViewGroup, ArrayList<Transition>>>> b = new ThreadLocal();
    public static ArrayList<ViewGroup> c = new ArrayList();

    /* compiled from: TransitionManager */
    public static class a implements OnPreDrawListener, OnAttachStateChangeListener {
        public Transition a;
        public ViewGroup b;

        /* compiled from: TransitionManager */
        public class a extends f {
            public final /* synthetic */ b.f.a a;

            public a(b.f.a aVar) {
                this.a = aVar;
            }

            public void e(Transition transition) {
                ((ArrayList) this.a.get(a.this.b)).remove(transition);
                transition.w(this);
            }
        }

        public a(Transition transition, ViewGroup viewGroup) {
            this.a = transition;
            this.b = viewGroup;
        }

        /* JADX WARNING: Removed duplicated region for block: B:12:0x005c  */
        /* JADX WARNING: Removed duplicated region for block: B:133:0x01ef A:{SYNTHETIC, EDGE_INSN: B:133:0x01ef->B:88:0x01ef ?: BREAK  , EDGE_INSN: B:133:0x01ef->B:88:0x01ef ?: BREAK  } */
        /* JADX WARNING: Removed duplicated region for block: B:19:0x009f  */
        /* JADX WARNING: Removed duplicated region for block: B:91:0x01f4  */
        /* JADX WARNING: Removed duplicated region for block: B:98:0x0215  */
        /* JADX WARNING: Removed duplicated region for block: B:104:0x0242  */
        public boolean onPreDraw() {
            /*
            r19 = this;
            r0 = r19;
            r1 = r0.b;
            r1 = r1.getViewTreeObserver();
            r1.removeOnPreDrawListener(r0);
            r1 = r0.b;
            r1.removeOnAttachStateChangeListener(r0);
            r1 = b.r.g.c;
            r2 = r0.b;
            r1 = r1.remove(r2);
            r2 = 1;
            if (r1 != 0) goto L_0x001c;
        L_0x001b:
            return r2;
        L_0x001c:
            r1 = b.r.g.a();
            r3 = r0.b;
            r3 = r1.get(r3);
            r3 = (java.util.ArrayList) r3;
            r4 = 0;
            if (r3 != 0) goto L_0x0036;
        L_0x002b:
            r3 = new java.util.ArrayList;
            r3.<init>();
            r5 = r0.b;
            r1.put(r5, r3);
            goto L_0x0042;
        L_0x0036:
            r5 = r3.size();
            if (r5 <= 0) goto L_0x0042;
        L_0x003c:
            r5 = new java.util.ArrayList;
            r5.<init>(r3);
            goto L_0x0043;
        L_0x0042:
            r5 = r4;
        L_0x0043:
            r6 = r0.a;
            r3.add(r6);
            r3 = r0.a;
            r6 = new b.r.g$a$a;
            r6.m7868init(r1);
            r3.a(r6);
            r1 = r0.a;
            r3 = r0.b;
            r6 = 0;
            r1.h(r3, r6);
            if (r5 == 0) goto L_0x0072;
        L_0x005c:
            r1 = r5.iterator();
        L_0x0060:
            r3 = r1.hasNext();
            if (r3 == 0) goto L_0x0072;
        L_0x0066:
            r3 = r1.next();
            r3 = (androidx.transition.Transition) r3;
            r5 = r0.b;
            r3.y(r5);
            goto L_0x0060;
        L_0x0072:
            r1 = r0.a;
            r8 = r0.b;
            java.util.Objects.requireNonNull(r1);
            r3 = new java.util.ArrayList;
            r3.<init>();
            r1.k = r3;
            r3 = new java.util.ArrayList;
            r3.<init>();
            r1.l = r3;
            r3 = r1.g;
            r5 = r1.h;
            r7 = new b.f.a;
            r9 = r3.a;
            r7.m5040init(r9);
            r9 = new b.f.a;
            r10 = r5.a;
            r9.m5040init(r10);
            r10 = 0;
        L_0x009a:
            r11 = r1.j;
            r12 = r11.length;
            if (r10 >= r12) goto L_0x01ef;
        L_0x009f:
            r11 = r11[r10];
            if (r11 == r2) goto L_0x01af;
        L_0x00a3:
            r12 = 2;
            if (r11 == r12) goto L_0x0161;
        L_0x00a6:
            r12 = 3;
            if (r11 == r12) goto L_0x010d;
        L_0x00a9:
            r12 = 4;
            if (r11 == r12) goto L_0x00af;
        L_0x00ac:
            r17 = r3;
            goto L_0x0109;
        L_0x00af:
            r11 = r3.c;
            r12 = r5.c;
            r13 = r11.i();
            r14 = 0;
        L_0x00b8:
            if (r14 >= r13) goto L_0x00ac;
        L_0x00ba:
            r15 = r11.j(r14);
            r15 = (android.view.View) r15;
            if (r15 == 0) goto L_0x00ff;
        L_0x00c2:
            r16 = r1.t(r15);
            if (r16 == 0) goto L_0x00ff;
        L_0x00c8:
            r17 = r3;
            r2 = r11.g(r14);
            r2 = r12.e(r2);
            r2 = (android.view.View) r2;
            if (r2 == 0) goto L_0x0101;
        L_0x00d6:
            r3 = r1.t(r2);
            if (r3 == 0) goto L_0x0101;
        L_0x00dc:
            r3 = r7.getOrDefault(r15, r4);
            r3 = (b.r.j) r3;
            r18 = r9.getOrDefault(r2, r4);
            r6 = r18;
            r6 = (b.r.j) r6;
            if (r3 == 0) goto L_0x0101;
        L_0x00ec:
            if (r6 == 0) goto L_0x0101;
        L_0x00ee:
            r4 = r1.k;
            r4.add(r3);
            r3 = r1.l;
            r3.add(r6);
            r7.remove(r15);
            r9.remove(r2);
            goto L_0x0101;
        L_0x00ff:
            r17 = r3;
        L_0x0101:
            r14 = r14 + 1;
            r3 = r17;
            r2 = 1;
            r4 = 0;
            r6 = 0;
            goto L_0x00b8;
        L_0x0109:
            r2 = r17;
            goto L_0x01e5;
        L_0x010d:
            r2 = r3;
            r3 = r2.b;
            r4 = r5.b;
            r6 = r3.size();
            r11 = 0;
        L_0x0117:
            if (r11 >= r6) goto L_0x01e5;
        L_0x0119:
            r12 = r3.valueAt(r11);
            r12 = (android.view.View) r12;
            if (r12 == 0) goto L_0x015c;
        L_0x0121:
            r13 = r1.t(r12);
            if (r13 == 0) goto L_0x015c;
        L_0x0127:
            r13 = r3.keyAt(r11);
            r13 = r4.get(r13);
            r13 = (android.view.View) r13;
            if (r13 == 0) goto L_0x015c;
        L_0x0133:
            r14 = r1.t(r13);
            if (r14 == 0) goto L_0x015c;
        L_0x0139:
            r14 = 0;
            r15 = r7.getOrDefault(r12, r14);
            r15 = (b.r.j) r15;
            r17 = r9.getOrDefault(r13, r14);
            r14 = r17;
            r14 = (b.r.j) r14;
            if (r15 == 0) goto L_0x015c;
        L_0x014a:
            if (r14 == 0) goto L_0x015c;
        L_0x014c:
            r0 = r1.k;
            r0.add(r15);
            r0 = r1.l;
            r0.add(r14);
            r7.remove(r12);
            r9.remove(r13);
        L_0x015c:
            r11 = r11 + 1;
            r0 = r19;
            goto L_0x0117;
        L_0x0161:
            r2 = r3;
            r0 = r2.d;
            r3 = r5.d;
            r4 = r0.c;
            r6 = 0;
        L_0x0169:
            if (r6 >= r4) goto L_0x01e5;
        L_0x016b:
            r11 = r0.k(r6);
            r11 = (android.view.View) r11;
            if (r11 == 0) goto L_0x01ac;
        L_0x0173:
            r12 = r1.t(r11);
            if (r12 == 0) goto L_0x01ac;
        L_0x0179:
            r12 = r0.h(r6);
            r12 = r3.get(r12);
            r12 = (android.view.View) r12;
            if (r12 == 0) goto L_0x01ac;
        L_0x0185:
            r13 = r1.t(r12);
            if (r13 == 0) goto L_0x01ac;
        L_0x018b:
            r13 = 0;
            r14 = r7.getOrDefault(r11, r13);
            r14 = (b.r.j) r14;
            r15 = r9.getOrDefault(r12, r13);
            r15 = (b.r.j) r15;
            if (r14 == 0) goto L_0x01ac;
        L_0x019a:
            if (r15 == 0) goto L_0x01ac;
        L_0x019c:
            r13 = r1.k;
            r13.add(r14);
            r13 = r1.l;
            r13.add(r15);
            r7.remove(r11);
            r9.remove(r12);
        L_0x01ac:
            r6 = r6 + 1;
            goto L_0x0169;
        L_0x01af:
            r2 = r3;
            r0 = r7.c;
        L_0x01b2:
            r0 = r0 + -1;
            if (r0 < 0) goto L_0x01e5;
        L_0x01b6:
            r3 = r7.h(r0);
            r3 = (android.view.View) r3;
            if (r3 == 0) goto L_0x01b2;
        L_0x01be:
            r4 = r1.t(r3);
            if (r4 == 0) goto L_0x01b2;
        L_0x01c4:
            r3 = r9.remove(r3);
            r3 = (b.r.j) r3;
            if (r3 == 0) goto L_0x01b2;
        L_0x01cc:
            r4 = r3.b;
            r4 = r1.t(r4);
            if (r4 == 0) goto L_0x01b2;
        L_0x01d4:
            r4 = r7.i(r0);
            r4 = (b.r.j) r4;
            r6 = r1.k;
            r6.add(r4);
            r4 = r1.l;
            r4.add(r3);
            goto L_0x01b2;
        L_0x01e5:
            r10 = r10 + 1;
            r0 = r19;
            r3 = r2;
            r2 = 1;
            r4 = 0;
            r6 = 0;
            goto L_0x009a;
        L_0x01ef:
            r0 = 0;
        L_0x01f0:
            r2 = r7.c;
            if (r0 >= r2) goto L_0x0210;
        L_0x01f4:
            r2 = r7.k(r0);
            r2 = (b.r.j) r2;
            r3 = r2.b;
            r3 = r1.t(r3);
            if (r3 == 0) goto L_0x020d;
        L_0x0202:
            r3 = r1.k;
            r3.add(r2);
            r2 = r1.l;
            r3 = 0;
            r2.add(r3);
        L_0x020d:
            r0 = r0 + 1;
            goto L_0x01f0;
        L_0x0210:
            r0 = 0;
        L_0x0211:
            r2 = r9.c;
            if (r0 >= r2) goto L_0x0231;
        L_0x0215:
            r2 = r9.k(r0);
            r2 = (b.r.j) r2;
            r3 = r2.b;
            r3 = r1.t(r3);
            if (r3 == 0) goto L_0x022e;
        L_0x0223:
            r3 = r1.l;
            r3.add(r2);
            r2 = r1.k;
            r3 = 0;
            r2.add(r3);
        L_0x022e:
            r0 = r0 + 1;
            goto L_0x0211;
        L_0x0231:
            r0 = androidx.transition.Transition.o();
            r2 = r0.c;
            r3 = b.r.m.a;
            r3 = new b.r.u;
            r3.m5139init(r8);
            r4 = 1;
            r2 = r2 - r4;
        L_0x0240:
            if (r2 < 0) goto L_0x02a3;
        L_0x0242:
            r4 = r0.h(r2);
            r4 = (android.animation.Animator) r4;
            r5 = 0;
            if (r4 == 0) goto L_0x02a0;
        L_0x024b:
            r6 = r0.getOrDefault(r4, r5);
            r6 = (androidx.transition.Transition.b) r6;
            if (r6 == 0) goto L_0x02a0;
        L_0x0253:
            r7 = r6.a;
            if (r7 == 0) goto L_0x02a0;
        L_0x0257:
            r7 = r6.d;
            r7 = r3.equals(r7);
            if (r7 == 0) goto L_0x02a0;
        L_0x025f:
            r7 = r6.c;
            r9 = r6.a;
            r10 = 1;
            r11 = r1.r(r9, r10);
            r12 = r1.n(r9, r10);
            if (r11 != 0) goto L_0x027b;
        L_0x026e:
            if (r12 != 0) goto L_0x027b;
        L_0x0270:
            r10 = r1.h;
            r10 = r10.a;
            r9 = r10.get(r9);
            r12 = r9;
            r12 = (b.r.j) r12;
        L_0x027b:
            if (r11 != 0) goto L_0x027f;
        L_0x027d:
            if (r12 == 0) goto L_0x0289;
        L_0x027f:
            r6 = r6.e;
            r6 = r6.s(r7, r12);
            if (r6 == 0) goto L_0x0289;
        L_0x0287:
            r6 = 1;
            goto L_0x028a;
        L_0x0289:
            r6 = 0;
        L_0x028a:
            if (r6 == 0) goto L_0x02a0;
        L_0x028c:
            r6 = r4.isRunning();
            if (r6 != 0) goto L_0x029d;
        L_0x0292:
            r6 = r4.isStarted();
            if (r6 == 0) goto L_0x0299;
        L_0x0298:
            goto L_0x029d;
        L_0x0299:
            r0.remove(r4);
            goto L_0x02a0;
        L_0x029d:
            r4.cancel();
        L_0x02a0:
            r2 = r2 + -1;
            goto L_0x0240;
        L_0x02a3:
            r9 = r1.g;
            r10 = r1.h;
            r11 = r1.k;
            r12 = r1.l;
            r7 = r1;
            r7.l(r8, r9, r10, r11, r12);
            r1.z();
            r0 = 1;
            return r0;
            */
            throw new UnsupportedOperationException("Method not decompiled: b.r.g$a.onPreDraw():boolean");
        }

        public void onViewAttachedToWindow(View view) {
        }

        public void onViewDetachedFromWindow(View view) {
            this.b.getViewTreeObserver().removeOnPreDrawListener(this);
            this.b.removeOnAttachStateChangeListener(this);
            g.c.remove(this.b);
            ArrayList arrayList = (ArrayList) g.a().get(this.b);
            if (arrayList != null && arrayList.size() > 0) {
                Iterator it = arrayList.iterator();
                while (it.hasNext()) {
                    ((Transition) it.next()).y(this.b);
                }
            }
            this.a.i(true);
        }
    }

    public static b.f.a<ViewGroup, ArrayList<Transition>> a() {
        b.f.a aVar;
        WeakReference weakReference = (WeakReference) b.get();
        if (weakReference != null) {
            aVar = (b.f.a) weakReference.get();
            if (aVar != null) {
                return aVar;
            }
        }
        aVar = new b.f.a();
        b.set(new WeakReference(aVar));
        return aVar;
    }
}
